package com.wy.ifly.mvp.p;

import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.OnLifecycleEvent;

import com.wy.ifly.mvp.v.IBaseView;

import java.lang.ref.WeakReference;

/**
 * Time:7/19/21
 * Author:ypf
 * Description:
 */
public class BasePresenter<T extends IBaseView> implements LifecycleObserver {

    protected WeakReference<T> iGoodView;

    public void attachView(T view) {
        this.iGoodView = new WeakReference<>(view);
    }

    public void detachView() {
        if (null != iGoodView) {
            iGoodView.clear();
            iGoodView = null;
        }
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
    void onCreate(LifecycleOwner owner) {

    }

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    void onDestroy(LifecycleOwner owner) {

    }

}
